
class Person {
    private String name;//只能在当前类里面访问
    public int age;

    public Person() {
        //不带参数的构造方法
    }


    public void getName(String name) {
        this.name = name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }



    //只能在类当中使用当前的属性
    private void eat() {

        System.out.println("吃饭！");
    }


    public Person(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public Person(int age) {
        this.age = age;
    }

    /*public String getName() {
        return this.name = name;
    }
    public void setName(String name) {
        this.name = name;
    }*/

    public String getName() {
        return name;
    }



    public void show() {

        System.out.println(name + "" + age);
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test {

    static boolean Paddy;
    public static void main(String args[]){
        System.out.println(Paddy);
    }
    public static void main2(String[] args) {
        Person person = new Person("zhangsan",10);
        //person.show();
    }
    //什么是封装
    //对类的细节进行隐藏，提供公开的接口来进行和数据交互
    public static void main1(String[] args) {
        Person person = new Person("zhangsan",10);
        person.setName("zhangsan");
        System.out.println(person.getName());
        person.show();
        /*person.name = "zhangsan";
        person.eat();*/
    }

}
